import { useSystemStore } from '@/stores/system'
const systemStore = useSystemStore()
export function getWeightUnit() {
  switch (systemStore.displayWeightType) {
    case '0':
      return '吨'
    case '1':
      return '千克'
  }
}
export function inputWeightToSave(val) {
  val = Number(val)
  switch (systemStore.displayWeightType) {
    case '0':
      break
    case '1':
      val /= 1000
  }
  return Number(val.toFixed(5))
}

export function saveWeightToShow(val) {
  val = Number(val)
  switch (systemStore.displayWeightType) {
    case '0':
      return Number(val.toFixed(5))
    case '1':
      return Number((val * 1000).toFixed(2))
  }
}

export function inputPriceToSave(val) {
  if (!val && val !== 0) {
    return ''
  }
  val = Number(val)
  switch (systemStore.displayWeightType) {
    case '0':
      break
    case '1':
      val *= 1000
  }
  return Number(val.toFixed(5))
}

export function savePriceToShow(val) {
  if (!val && val !== 0) {
    return '-'
  }
  val = Number(val)
  switch (systemStore.displayWeightType) {
    case '0':
      return Number(val.toFixed(5))
    case '1':
      return Number((val / 1000).toFixed(2))
  }
}
